package com.domino.client.view;

import com.domino.client.mvc.Controller;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.VerticalPanel;

public class NotificationPanel {
	
	PopupPanel popup;
	Panel infoPanel;
	HTML infoLabel;
	Image infoImage;
	UIObject target;

	public NotificationPanel(UIObject target) {
		this.target = target;
		popup = new PopupPanel();
		popup.setGlassEnabled(false);
		popup.setStyleName("message-popup");
		infoPanel = new HorizontalPanel();
		//infoPanel.setStyleName("message-popup");
		popup.add(infoPanel);
		
		infoLabel = new HTML();
		infoLabel.setStyleName("message-popup-info");
		infoImage = new Image();
		infoImage.setStyleName("message-popup-wait");
		infoPanel.add(infoLabel);
	}
	
	public void showWait(String message) {
		infoLabel.setHTML(message);
		infoImage.setUrl("imgs/wait.gif");
		popup.showRelativeTo(target);
	}
	
	public void showLeftGame() {
		showWait("You left the game! &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"/\">[Play again]</a>");
	}
	
	public void gameFinished(int colorCountBlack, int colorCountWhite) {
		String winner = colorCountBlack>colorCountWhite?"The winner is BLACK!":"The winner is WHITE!";
		winner = colorCountBlack==colorCountWhite?"REMI":winner;
		String message = winner + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"/\">[Play again]</a>";
		showWait(message);
	}
	
	public void hide() {
		popup.hide();
	}


}
